<template>
  <div class="item" style="position: relative">
    <image-block @click.native="gotoUrl(domain+'/MinProgram2/Article/detail_o?article_id='+dInfo.article_id)" :img-src="domain+'/Uploads'+dInfo.article_cover" width="100%" height="auto">
      <div slot="leftBottom" style="width: 9.4rem" v-if="dUserinfo.is_me">
        <div class="flex" style="justify-content: space-between;margin-bottom: .1rem;">
          <div class="flex-item"><i class="btn fa fa-pencil" @click.stop="gotoUrl(domain+'/MinProgram2/Article/upload?article_id='+dInfo.article_id)"> 编辑</i></div>
          <div class="flex-item"><i class="btn fa fa-arrow-up"  @click.stop="SetToTop(pInfo.article_id)">置顶</i></div>
          <div class="flex-item"><i class="btn fa fa-remove"  @click.stop="deleteDo(pInfo.article_id)"> 删除</i></div>
        </div>
      </div>
    </image-block>
    <div class="flex">
      <div class="flex-item" style="flex: 4;text-align: left">
        <div class="article_title midfont">{{dInfo.article_title}}</div>
        <div class="articles_addtime_text minifont">发布于 {{dInfo.articles_addtime_text}}</div>
      </div>
      <div class="flex-item" style="flex: 1;">
        <like-count class="likeCount" :article_id="dInfo.article_id"  :pme_is_like="dInfo.me_is_like"></like-count>
      </div>
    </div>
  </div>
</template>
<style scoped>
.article_title{white-space: nowrap;max-width: 8rem;text-overflow:ellipsis;overflow: hidden}
.btn{background-color: white;width: 2rem}
.SetTop{position: absolute !important;top: .05rem !important; left: .8rem !important;}
.likeCount{margin-top: .3rem;margin-left: .5rem;}
</style>
<script>
import ImageBlock from "../images/ImageBlock";
import SetTop from "@/components/buttons/SetTop";
import LikeCount from "./likeCount";
export default {
  props:{
    dUserinfo:{
      type:Object,
      default:null
    },
    pInfo:{
      type:Object,
      default:null
    }
  },
  data(){
    return {
      dInfo:this.pInfo
    }
  },
  watch:{
    pInfo(n){
      this.dInfo = n
    }
  },
  methods:{
    SetToTop(article_id){
      this.$emit('SetToTop',article_id)
    },
    deleteDo(article_id){
      this.$emit('DeleteDo',article_id)
    }
  },
  components: {LikeCount, ImageBlock,SetTop}
}
</script>
